//
//  loginModel.m
//  XYMaterial
//
//  Created by 肖扬 on 15/12/11.
//  Copyright © 2015年 肖扬. All rights reserved.
//

#import "loginModel.h"

@implementation loginModel
@synthesize data;
-(id)init{
    self = [super init];
    if (self) {
        self.data = [NSMutableDictionary dictionary];
    }
    return self;
}
-(void)parseResponseData:(NSString *)responseString{
    [super parseResponseData:responseString];
    NSMutableDictionary *dic = [responseString objectFromJSONString];
    NSString *errCode = [dic objectForKey:@"err_code"];
    if ([errCode integerValue] != 0){ //普通错误  无需提示
        return;
    }
    NSMutableDictionary *dict = [dic objectForKey:@"data"];
//    myInfoModel *infoModel = [[myInfoModel alloc]init];
    NSMutableDictionary *infoDic = [NSMutableDictionary dictionary];
    if (![Unity isBlankString:[dict objectForKey:@"nickname"]]) {
        [infoDic setObject:[dict objectForKey:@"nickname"] forKey:@"nickname"];
    }else{
        [infoDic setObject:@"" forKey:@"nickname"];
    }
    if (![Unity isBlankString:[dict objectForKey:@"mobile"]]) {
        [infoDic setObject:[dict objectForKey:@"mobile"] forKey:@"mobile"];
    }else{
        [infoDic setObject:@"" forKey:@"mobile"];
    }
    if (![Unity isBlankString:[dict objectForKey:@"mobile_verified"]]) {
        [infoDic setObject:[dict objectForKey:@"mobile_verified"] forKey:@"mobile_verified"];
    }else{
        [infoDic setObject:@"" forKey:@"mobile_verified"];
    }
    if (![Unity isBlankString:[dict objectForKey:@"email"]]) {
        [infoDic setObject:[dict objectForKey:@"email"] forKey:@"email"];
    }else{
        [infoDic setObject:@"" forKey:@"email"];
    }
    if (![Unity isBlankString:[dict objectForKey:@"license_status"]]) {
        [infoDic setObject:[dict objectForKey:@"license_status"] forKey:@"license_status"];
    }else{
        [infoDic setObject:@"" forKey:@"license_status"];
    }
    [[NSUserDefaults standardUserDefaults] setObject:infoDic forKey:@"myInfo"];
    
    loginModelObj *model = [[loginModelObj alloc]init];
    model.nickname = [dict objectForKey:@"nickname"];
    model.mobile = [dict objectForKey:@"mobile"];
    model.mobile_verified = [dict objectForKey:@"mobile_verified"];
    model.company_name = [dict objectForKey:@"company_name"];
    model.qq = [dict objectForKey:@"qq"];
    
    model.email = [dict objectForKey:@"email"];
    model.status = [dict objectForKey:@"status"];
    model.dealer = [dict objectForKey:@"dealer"];
    model.referee = [dict objectForKey:@"referee"];
    model.certificate = [dict objectForKey:@"certificate"];
    
    model.mid = [dict objectForKey:@"mid"];
    model.client_model = [dict objectForKey:@"client_model"];
    model.client_os = [dict objectForKey:@"client_os"];
    model.client_os_version = [dict objectForKey:@"client_os_version"];
    model.client_latitude = [dict objectForKey:@"client_latitude"];
    
    model.client_longitude = [dict objectForKey:@"client_longitude"];
    model.client_device = [dict objectForKey:@"client_device"];
    model.app_version = [dict objectForKey:@"app_version"];
    model.ctime = [dict objectForKey:@"ctime"];
    [self.data setObject:model forKey:@"userInfo"];
}
-(void)dealloc{
    [self.data removeAllObjects];
    self.data = nil;
}
@end

@implementation loginModelObj

@synthesize nickname,mobile,mobile_verified,company_name,qq;
@synthesize email,status,dealer,referee,certificate;
@synthesize mid,client_model,client_os,client_os_version,client_latitude;
@synthesize client_longitude,client_device,app_version,ctime;
-(void)dealloc{
    self.nickname = nil;
    self.mobile_verified = nil;
    self.mobile = nil;
    self.company_name = nil;
    self.qq = nil;
    
    self.email = nil;
    self.status = nil;
    self.dealer = nil;
    self.referee = nil;
    self.certificate = nil;
    
    self.mid = nil;
    self.client_model = nil;
    self.client_os = nil;
    self.client_os_version = nil;
    self.client_latitude = nil;
    
    self.client_longitude = nil;
    self.client_device = nil;
    self.app_version = nil;
    self.ctime = nil;
}

@end

@implementation myInfoModel

@synthesize nickName,mobile,mobile_verified,email,license_status;
-(id)init{
    self = [super init];
    if (self) {
        self.nickName = @"";
        self.mobile = @"";
        self.mobile_verified = @"";
        self.email = @"";
        self.license_status = @"";
    }
    return self;
}

@end